home *** CD-ROM | disk | FTP | other *** search
- Path: kbad.eglin.af.mil!rpi!not-for-mail
- From: floydb1@lib104.its.rpi.edu (Barry B Floyd)
- Newsgroups: comp.lang.c++
- Subject: Re: Virtual functions in derived classes
- Date: 10 Jan 1996 10:26:19 -0500
- Organization: Rensselaer Polytechnic Institute, Troy, NY.
- Message-ID: <4d0lqr$aa8@lib104.its.rpi.edu>
- References: <30ECA10F.3D99@ifu.net> <NITIN.96Jan5125830@more.eng.sun.com> <4crquj$7t1@lib108.its.rpi.edu> <NITIN.96Jan9103242@more.eng.sun.com> <ALUN.CHAMPION.96Jan9152102@g7240065.bridge.bst.bls.com> <NITIN.96Jan9170606@more.eng.sun.com>
- NNTP-Posting-Host: lib104.its.rpi.edu
- X-newsreader: xrn 7.04-beta-11
-
-
- In article <NITIN.96Jan9170606@more.eng.sun.com>, nitin@more.eng.sun.com (Nitin More [CONTRACTOR]) writes:
- >
- >
- > Alan,
- >
- > Thanks for clarifying that ...
- >
- > > If a virtual member function vf is declared in a class Base and in a
- class
- > > Derived, derived directly or indirectly from Base, a member function
- vf with
- > > the same name and same parameter list as Base::vf is declared, then
- > > Derived::vf is also virtual (whether or not it is so declared) and it
- > > overrides Base::vf. ...
- > > ...
- >
- >
- > This is Yuck! since sometimes you might not want the user of your
- class
- > library to overwrite your methods but want to use the virtual methods
- > in implementing the class library.
- >
- > -Nitin
-
- The user is the one providing the method's code, the librarian is
- only declaring that the function must exist in order to conform to
- the requirements of the entire class.
-
- Base::Function ( int, int ) = 0 ; // no implementation.
- DerivedDerived::Function ( int, int ) ; // inherits...
- Derived::Function ( int, int ) {code} ; // when implemented.
-
- --
- +--------------------------------------------------------------------+
- | Barry B. Floyd \\\ floydb1@rpi.edu |
- | RPI Alum. '84 '87 '88 \\\ |
- +--------------------------------------------------------------------+
-